package com.firewolf.shiro.dao;

import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

import com.firewolf.shiro.entities.User;
public class UserDaoImpl extends JdbcDaoSupport implements UserDao {


    @SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
    public User findByUsername(String username) {
        String sql = "select id, username, password, salt, locked from sys_users where username=?";
        List<User> userList = getJdbcTemplate().query(sql, new BeanPropertyRowMapper(User.class), username);
        if(userList.size() == 0) {
            return null;
        }
        return userList.get(0);
    }

}
